<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <title>产品生产工序单设计变更</title>
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
    <link rel="stylesheet" href="../../../lib/layui-v2.5.5/css/layui.css" media="all">
    <link rel="stylesheet" href="../../../css/public.css" media="all">
</head>
<body>
<div id="addGx1">
<div id="addG2" style="display: none;">
    <form  class="layui-form" >
        <div class="layui-inline">
            <label class="layui-form-label">搜索选择框</label>
            <div class="layui-input-inline">
                <select name="modules" id="gxTypeVal"  lay-verify="required" lay-search="">
                    <option value="">直接选择或搜索选择</option>
                    <option value="1">组装</option>
                    <option value="2">测试</option>
                    <option value="3">包装</option>
                </select>
            </div>
        </div>
    </form>
        <div class="layui-form-item">
            <div class="layui-input-block" style=" margin-left: 158px;
    margin-top: 42px;">

                <button type="button"  id="addGxButton" style="    display: inline-block;
    height: 38px;
    line-height: 38px;
    padding: 0 18px;
    background-color: #009688;
    color: #fff;
    white-space: nowrap;
    text-align: center;
    font-size: 14px;
    border: none;
    border-radius: 2px;
    cursor: pointer;">立即提交</button>
            </div>
        </div>

</div>
</div>
<!--添加模态框-->
<div id="">

    <div id="addSupper" style="display: none;">
        <fieldset class="layui-elem-field layui-field-title" style="margin-top: 20px;">
            <legend style="    margin-left: 404px;">生产工序设计单</legend>
        </fieldset>

        <form action="" class="layui-form" lay-filter="">
            <div class="layui-form-item">
                <label class="layui-form-label" style="    margin-left: 70px;">产品名称 :</label>
                <div class="layui-input-inline">
                <input autocomplete="off"  readonly="readonly" style="  border: 0px;   width: 307px;" class="layui-input" id="product_name" lay-verify="required" name="product_name"
                       placeholder="" type="text">

            </div>
                <label class="layui-form-label" style="    margin-left: 165px;">产品编号 :</label>
                <div class="layui-input-inline">
                    <input autocomplete="off"  readonly="readonly" style="  border: 0px;   width: 307px;" class="layui-input" id="procedure_id" lay-verify="required" name="procedure_id"
                           placeholder="" type="text">

                </div>
            </div>
            <div class="layui-form-item">
                <label class="layui-form-label" style="    margin-left: 70px;">设计人 :</label>
                <div class="layui-input-inline">
                    <input autocomplete="off" readonly="readonly"  style="  border: 0 ;  width: 307px;" class="layui-input" id="product_designer" lay-verify="required" name="product_designer"
                           placeholder="请输入设计人的名称" type="text">

                </div>
                <label class="layui-form-label" style="    margin-left: 165px;">设计单编号 :</label>
                <div class="layui-input-inline">
                    <input autocomplete="off"  readonly="readonly" style="  border: 0px;   width: 307px;" class="layui-input" id="design_number" lay-verify="required" name="design_number"
                           placeholder="" type="text">

                </div>
                <input autocomplete="off"  style="    width: 307px;" class="layui-input" id="prdouctId" lay-verify="required" name="prdouctId"
                       placeholder="请输入设计人的名称" type="hidden">

            </div>
            <table class="layui-table" id="test3" lay-filter="test3">

            </table>
            <div class="layui-form-item">
                <label class="layui-form-label" style="    margin-left: 70px;">登记人 :</label>
                <div class="layui-input-inline">
                    <input autocomplete="off"  readonly="readonly" style=" border: 0;    width: 307px;" class="layui-input" id="register" lay-verify="required" name="register"
                           placeholder="请输入登记人的名称" type="text">

                </div>
                <label class="layui-form-label" style="        margin-left: 137px;">审核时间 :</label>
                <div class="layui-input-inline">
                    <input autocomplete="off"   style="    width: 307px;" class="layui-input" id="audit_date" lay-verify="required" name="audit_date"
                           placeholder="请选择审核的时间" type="text">

                </div>

            </div>
            <div class="layui-form-item layui-form-text">
                <label class="layui-form-label">设计要求</label>
                <div class="layui-input-block">
                    <textarea placeholder="请输入内容" class="layui-textarea"></textarea>
                </div>
            </div>
            <div class="layui-form-item">
                <div class="layui-input-block" style="    margin-left: 370px;">
                        <input type="radio" name="sex" value="通过" title="通过" checked="">
                        <input type="radio" name="sex" value="未通过" title="未通过">
                    <input type="hidden" id="gprocuJson" name="gprocuJson">
                    <input type="hidden" id="shdId" name="shdId">
                    <input type="hidden" id="sjdId" name="sjdId">
                    <button type="button" id="addProduction_process_design" class="layui-btn"  >立即提交</button>
                </div>
            </div>
        </form>
    </div>
</div>

<div id="editSupper1">

    <div id="editSupper" style="display: none;">
        <fieldset class="layui-elem-field layui-field-title" style="margin-top: 20px;">
            <legend style="    margin-left: 404px;">变更设计单</legend>
        </fieldset>

        <form action="" class="layui-form" lay-filter="">
            <div class="layui-form-item">
                <label class="layui-form-label" style="    margin-left: 70px;">产品名称 :</label>
                <div class="layui-input-inline">
                    <input autocomplete="off"  readonly="readonly" style="  border: 0px;   width: 307px;" class="layui-input" id="product_name1" lay-verify="required" name="product_name1"
                           placeholder="" type="text">

                </div>
                <label class="layui-form-label" style="    margin-left: 165px;">产品编号 :</label>
                <div class="layui-input-inline">
                    <input autocomplete="off"  readonly="readonly" style="  border: 0px;   width: 307px;" class="layui-input" id="procedure_id1" lay-verify="required" name="procedure_id1"
                           placeholder="" type="text">

                </div>
            </div>
            <div class="layui-form-item">
                <label class="layui-form-label" style="    margin-left: 70px;">设计人 :</label>
                <div class="layui-input-inline">
                    <input autocomplete="off" readonly="readonly"  style="  border: 0 ;  width: 307px;" class="layui-input" id="product_designer1" lay-verify="required" name="product_designer1"
                           placeholder="请输入设计人的名称" type="text">

                </div>
                <label class="layui-form-label" style="    margin-left: 165px;">设计单编号 :</label>
                <div class="layui-input-inline">
                    <input autocomplete="off"  readonly="readonly" style="  border: 0px;   width: 307px;" class="layui-input" id="design_number1" lay-verify="required" name="design_number1"
                           placeholder="" type="text">

                </div>
                <input autocomplete="off"  style="    width: 307px;" class="layui-input" id="prdouctId1" lay-verify="required" name="prdouctId1"
                       placeholder="请输入设计人的名称" type="hidden">

            </div>
            <table class="layui-table" id="test4" lay-filter="test4">

            </table>
            <div class="layui-form-item">
                <label class="layui-form-label" style="    margin-left: 70px;">登记人 :</label>
                <div class="layui-input-inline">
                    <input autocomplete="off"  readonly="readonly" style=" border: 0;    width: 307px;" class="layui-input" id="register1" lay-verify="required" name="register1"
                           placeholder="请输入登记人的名称" type="text">

                </div>
                <label class="layui-form-label" style="        margin-left: 137px;">修改时间 :</label>
                <div class="layui-input-inline">
                    <input autocomplete="off"   style="    width: 307px;" class="layui-input" id="audit_date1" lay-verify="required" name="audit_date1"
                           placeholder="请选择修改的时间" type="text">

                </div>

            </div>
            <div class="layui-form-item layui-form-text">
                <label class="layui-form-label">设计要求</label>
                <div class="layui-input-block">
                    <textarea placeholder="请输入内容" class="layui-textarea"></textarea>
                </div>
            </div>
            <div class="layui-form-item">
                <div class="layui-input-block" style="    margin-left: 370px;">
                    <input type="hidden" id="gprocuJson1" name="gprocuJson">
                    <input type="hidden" id="shdId1" name="shdId1">
                    <input type="hidden" id="sjdId1" name="shdId1">
                    <button type="button" id="addProduction_process_design1" class="layui-btn"  >立即提交</button>
                </div>
            </div>
        </form>
    </div>
</div>
<blockquote class="layui-elem-quote news_search" style=" border-left: 0px solid #009688;">
    <div class="layui-row">
        <form class="layui-form layui-col-md12 x-so" id="complain_search">
            建档时间:
            <div class="layui-input-inline">
                <input type="text" name="date" id="date" autocomplete="off" class="layui-input">


            </div>至
            <div class="layui-input-inline">
                <input type="text" name="date1" id="date1" autocomplete="off" class="layui-input">


            </div>
            <button id="search" class="layui-btn" lay-submit
                    lay-filter="provinceSearch">
                <i class="layui-icon">&#xe615;</i>
            </button>
        </form>
    </div>
    <table class="layui-hide" id="complainTable" lay-filter="complainList"></table>
</blockquote>

<script type="text/html" id="complain_toolbar">
    <div class="layui-btn-container">
    </div>


</script>
<script type="text/html" id="barDemo2">
</script>
<script type="text/html" id="barDemo">
    <a class="layui-btn layui-btn-xs" lay-event="edit">审核</a>
    <a class="layui-btn layui-btn-xs" lay-event="edit1">修改</a>
</script>

<script src="../../../lib/jquery-3.4.1/jquery-3.4.1.min.js" charset="utf-8"></script>
<script src="../../../lib/layui-v2.5.5/layui.js" charset="utf-8"></script>
<script src="../../../js/lay-config.js?v=1.0.4" charset="utf-8"></script>
<script src="../../../lib/jq-module/jquery.particleground.min.js" charset="utf-8"></script>
<script src="../../../lib/common/jquery.cookie.min.js" charset="utf-8"></script>
<script src="../../../lib/common/common.js" charset="utf-8"></script>
<!-- 注意：如果你直接复制所有代码到本地，上述js路径需要改成你本地的 -->

<script type="text/javascript" >
    layui.use(['table','layer','form','laypage'], function(){
        var table = layui.table,
            layer = layui.layer,
            form = layui.form,
            laypage = layui.laypage;

        var tableIns =  table.render({
            id:"provinceReload"
            ,elem: '#complainTable'
            ,url:'http://localhost:8003/production/getAllProduct_alteration'
            ,page: true
            ,toolbar: '#complain_toolbar'
            ,cols: [[ //表头
                {type: 'checkbox', fixed: 'left'}
                ,{field: 'id', title: 'ID',  hide:true}
                , {field: 'production_process_design_sheet', title: '设计单编号', width: 340, templet: '<div>{{d.production_process_design_sheet.design_number}}</div>'},
                {field: 'production_process_design_sheet', title: '产品编号', width: 340, templet: '<div>{{d.production_process_design_sheet.audit_date}}</div>'}
                ,  {field: 'edit_date', title: '变更时间', width: 340, templet: '<div></div>'},
                {field: 'edit_count', title: '变更次数', width: 340,},
                {field: 'userName', title: '操作人员', width: 220,}
            ]]
            ,limits: [5,10,20,50]
        });

        table.on('toolbar(complainList)', function(obj) {
            var checkStatus = table.checkStatus(obj.config.id),
                data = checkStatus.data;
            data = eval("(" + JSON.stringify(data) + ")");
            switch(obj.event) {
                case 'add':
                    break;
                case 'getCheckData':
                    var data = checkStatus.data;
                    layer.alert(JSON.stringify(data));
                    break;
                case 'Supperdeletes':

                    break;
            }
        });
    $("#addProduction_process_design").click(function () {
        var delIndex = layer.confirm('确定提交吗', function(delIndex) {
            layui.use('table',function () {
                var table = layui.table;
            datas = layui.table.cache["test3"];
                var product_name = $("#product_name").val();
                var design_idB = $("#procedure_id").val();
                var product_designer  =$("#product_designer").val();
                var product_registrant  =$("#register").val();
                var  audit_date = $("#audit_date").val();
                var  esign_require = $(".layui-textarea").val();
             var shState =   $("input[name='sex']:checked").val();
            var sjdId = $("#sjdId").val();
            var shdId = $("#shdId").val();
        if(audit_date==""){
            layer.msg("请选择审核时间");
            return;
        }
        if(shState=='通过'){

            $.ajax({
                url:'http://127.0.0.1:8003/productaudit/auditSjdShb',
                data:{"shState":shState,"audit_date":audit_date,"sjdId":sjdId,"shdId":shdId},
                success: function (data) {
                    layer.msg("提交成功");
                    window.parent.location.reload();//刷新父页面
                    layer.closeAll();
                }
            })
        }else if (shState=='未通过') {
            window.parent.location.reload();//刷新父页面
            layer.closeAll();
            return;

        }


            })


        });
    })

        $("#addProduction_process_design1").click(function () {
            var delIndex = layer.confirm('确定提交吗', function(delIndex) {
                layui.use('table',function () {
                    var table = layui.table;
                    datas = layui.table.cache["test4"];
                    var product_name = $("#product_name1").val();
                    var design_idB = $("#procedure_id1").val();
                    var product_designer  =$("#product_designer1").val();
                    var product_registrant  =$("#register1").val();
                    var  audit_date = $("#audit_date1").val();
                    var  esign_require = $(".layui-textarea").val();
                    var sjdId = $("#sjdId1").val();
                    var shdId = $("#shdId1").val();
                    let userName = JSON.parse(localStorage.getItem("user"));

                    if(audit_date==""){
                        layer.msg("请选择修改时间");
                        return;
                    }
                        $.ajax({
                            url:'http://127.0.0.1:8003/productaudit/edittSjdShb',
                            data:{
                                'userName':userName,
                                'product_name': product_name,
                                'design_idB': design_idB,
                                'product_designer': product_designer,
                                'product_registrant': product_registrant,
                                'edie_date': audit_date,
                                'sjdId':sjdId,
                                'shdId':shdId,
                                'gprocuJson1': JSON.stringify(datas)
                            },
                            success: function (data) {
                                layer.msg("提交成功");
                                window.parent.location.reload();//刷新父页面
                                layer.closeAll();
                            }
                        })





                })


            });
        })
        table.on('tool(complainList)', function(obj) {
            var data = obj.data;
            json = JSON.stringify(data);
            switch(obj.event) {
                case 'detail':
                    break;
                case 'edit':
                    $("#sjdId").val(data.design_id.id);
                    $("#shdId").val(data.design_idA)
                    table.render({
                        elem: '#test3',
                        url:'http://localhost:8003/designprocess/getAllDid?design_id='+data.design_id.design_idB,
                        height:150
                        ,cols: [[
                            {field:'id', width:120, title: '序号', },
                            {field:'process_name', width:110, title: '工序名称', }
                            ,{field:'process_id', width:150, title: '工序编号'}
                            ,{field:'process_describe', width:120, title: '工序描述', }
                            ,{field:'process_time_gs', width:120, title: '工时数', }
                            ,{field:'process_time_unitdw', title: '工时单位', width: 120, }
                            ,{field:'process_time_cost', width:120, title: '单位工时成本'}
                            ,{field:'process_subtotal', width:120, title: '工时成本小计', }

                        ]],


                    });

                    $("#product_name").val(data.design_id.product_name);
                    $("#procedure_id").val(data.design_id.design_idB);
                    $("#product_designer").val(data.design_id.product_registrant);
                    $("#design_number").val(data.design_id.design_number);
                    $("#register").val(data.design_id.product_registrant);
                    $("#register_time").val(data.design_id.design_date);
                    $(".layui-textarea").val(data.design_id.esign_require)
                    $("#prdouctId").val(data.id);

                    layer.open({
                        maxmin: true,
                        type: 1,//类型 信息
                        area: ['1000px', '600px'],//定义宽和高
                        title: '设计单审核',//题目
                        shadeClose: false,//点击遮罩层关闭
                        content: $('#addSupper')//打开的模态框

                    });
                    break;
                case 'edit1':
                    $("#sjdId1").val(data.design_id.id);
                    $("#shdId1").val(data.design_idA)
                    table.render({
                        elem: '#test4',
                        url:'http://localhost:8003/designprocess/getAllDid?design_id='+data.design_id.design_idB,
                        height:150
                        ,cols: [[
                            {field:'id', width:120, title: '序号', },
                            {field:'process_name', width:130, title: '工序名称',edit:true, }
                            ,{field:'process_id', width:150, title: '工序编号',edit:true,}
                            ,{field:'process_describe', width:130, title: '工序描述', edit:true,}
                            ,{field:'process_time_gs', width:150, title: '工时数',edit:true, }
                            ,{field:'process_time_unitdw', title: '工时单位', width: 150, edit:true,}
                            ,{field:'process_time_cost', width:150, title: '单位工时成本',edit:true,}

                        ]],


                    });

                    $("#product_name1").val(data.design_id.product_name);
                    $("#procedure_id1").val(data.design_id.design_idB);
                    $("#product_designer1").val(data.design_id.product_registrant);
                    $("#design_number1").val(data.design_id.design_number);
                    $("#register1").val(data.design_id.product_registrant);
                    $("#register_time1").val(data.design_id.design_date);
                    $(".layui-textarea").val(data.design_id.esign_require)
                    $("#prdouctId1").val(data.id);

                    layer.open({
                        maxmin: true,
                        type: 1,//类型 信息
                        area: ['1000px', '600px'],//定义宽和高
                        title: '设计单审核',//题目
                        shadeClose: false,//点击遮罩层关闭
                        content: $('#editSupper')//打开的模态框

                    });

                    break;
            }
        });
        //监听提交
        form.on('submit(supperSub)', function(data){
            var edC=  $("#edidId").val();
            if(edC==1){
                $.ajax({
                    url:'http://127.0.0.1:8005/supper/updateSupperById',
                    data:data.field,
                    success: function (data) {
                        layer.msg("提交成功")
                    }
                })
            }
            if(edC!=1){
                $.ajax({
                    url:'http://127.0.0.1:8005/supper/insertSupper',
                    data:data.field,
                    success: function (data) {
                        layer.msg("提交成功")
                    }
                })
                return;
            }
            layer.alert(JSON.stringify(data.field), {
                title: '最终的提交信息'
            })






        });


        form.render();
        form.on('submit(provinceSearch)', function(data) {
            var formData = data.field;
            var serviceCode = formData.serviceCode,
                compOrder = formData.compOrder,
                compType = formData.compType,
                complainState = formData.complainState;
            table.reload('provinceReload', {
                page: {
                    curr: 1
                },

                url: 'http://127.0.0.1:8005/supper/sellName?name='+formData.name,
            });
            return false;
        });

    });
    layui.use(['form', 'layedit', 'laydate'], function(){
        var form = layui.form
            ,layer = layui.layer
            ,layedit = layui.layedit
            ,laydate = layui.laydate;

        //日期
        laydate.render({
            elem: '#date'
        });
        laydate.render({
            elem: '#date1'
        });
        laydate.render({
            elem: '#audit_date'
        });
        laydate.render({
            elem: '#audit_date1'
        });




        //监听提交
        form.on('submit(demo1)', function(data){
            layer.alert(JSON.stringify(data.field), {
                title: '最终的提交信息'
            })
            return false;
        });

        //表单赋值
        layui.$('#LAY-component-form-setval').on('click', function(){
            form.val('example', {
                "username": "贤心" // "name": "value"
                ,"password": "123456"
                ,"interest": 1
                ,"like[write]": true //复选框选中状态
                ,"close": true //开关状态
                ,"sex": "女"
                ,"desc": "我爱 layui"
            });
        });

        //表单取值
        layui.$('#LAY-component-form-getval').on('click', function(){
            var data = form.val('example');
            alert(JSON.stringify(data));
        });

    });
    layui.use('table', function(){
        var table = layui.table;
        var AddData=[
        ];
        table.on('tool(test3)', function(obj){
            var data = obj.data;
            //console.log(obj)
            if(obj.event === 'del'){
                layer.confirm('真的删除行么', function(index){
                    console.log(index)
                    AddData.splice($.inArray(index,AddData),1);
                    obj.del();
                    layer.close(index);
                });
            }
        });
        $("#addGxButton").click(function () {

            var  datas=   layui.table.cache["test3"];
            var gxType = $(".layui-input").val();
            var gId =$("#gxTypeVal").val();
            var data1={"process_name":gxType,"process_id":gId};
            AddData.unshift(data1);
            console.log(AddData)
            table.reload('test3',{
                data : AddData
            });

        });
     //  form.on('submit(test-submit-add)', function (data) {
      //      table.cache['test3'].push(data.field);
       //     table.reload('test3', { data: table.cache['test3']});


    //    });
        //监听行工具事件

        //监听单元格编辑
        table.on('edit(test3)', function(obj){
            var value = obj.value //得到修改后的值
                ,data = obj.data //得到所在行所有键值
                ,field = obj.field; //得到字段
         //   layer.msg('[ID: '+ data.id +'] ' + field + ' 字段更改为：'+ value);
        });
    });
</script>


</body>
</html>
